1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| #include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) #define rep(i, x, y) for (register int i = x; i <= y; i++) using namespace std;
const int N = 110, M = 2e4 + 10, mod = 998244353, G = 3, G1 = (mod + 1) / G; typedef long long ll; ll n, m, lim = 1; ll fac[M], inv[M], r[M], h[M], f[N][M], g[N][M], c[N][N];
inline ll quick_pow(ll a, ll b) { ll ret = 1; for (; b; b >>= 1) { if (b & 1) ret = ret * a % mod; a = a * a % mod; } return ret; }
inline void init() { fac[0] = inv[0] = inv[1] = 1; rep(i, 1, m) fac[i] = fac[i - 1] * i % mod; rep(i, 2, m) inv[i] = (mod - mod / i) * inv[mod % i] % mod; rep(i, 2, m) inv[i] = inv[i - 1] * inv[i] % mod; int l = 0; while (lim < m * 2) lim <<= 1, ++l; rep(i, 0, lim - 1) r[i] = (r[i >> 1] >> 1) | ((i & 1) << (l - 1));
c[0][0] = 1; rep(i, 1, n) { c[i][0] = 1; rep(j, 1, n) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod; } }
inline ll C(ll n, ll m) { return fac[n] * inv[m] % mod * inv[n - m] % mod; }
inline void NTT(ll a[], int op) { rep(i, 0, lim - 1) if (i < r[i]) swap(a[i], a[r[i]]); for (int mid = 1; mid < lim; mid <<= 1) { ll W = quick_pow(op == 1 ? G : G1, (mod - 1) / (mid << 1)); for (int j = 0; j < lim; j += (mid << 1)) { ll w = 1; for (int k = 0; k < mid; k++, w = w * W % mod) { ll x = a[j + k], y = w * a[j + k + mid] % mod; a[j + k] = (x + y) % mod, a[j + k + mid] = (x - y + mod) % mod; } } } if (op == -1) { ll Inv = quick_pow(lim, mod - 2); rep(i, 0, lim - 1) a[i] = a[i] * Inv % mod; } }
int main() { scanf("%lld", &n); m = n * (n - 1) / 2; init(); rep(i, 1, n) { rep(j, 0, i * (i - 1) / 2) g[i][j] = C(i * (i - 1) / 2, j); NTT(g[i], 1); } rep(i, 1, n) { rep(j, 0, lim - 1) { h[j] = 0; rep(k, 1, i - 1) h[j] = (h[j] + c[i - 1][k - 1] * f[k][j] % mod * g[i - k][j] % mod) % mod; f[i][j] = (g[i][j] - h[j] + mod) % mod; } } NTT(f[n], -1); rep(i, 0, m) printf("%lld\n", f[n][i]); return 0; }
|